<?php
session_start();
require_once 'header.php';
function __autoload($className)
	{
    	require_once('class/' . $className . '.class.php');
	}
if($_POST)
{
	
	

     $user=strval(rtrim(trim($_POST["user"])));
	$pass1=strval(rtrim(trim($_POST["pass"])));
	$pass2=strval(rtrim(trim($_POST["confirmpass"])));
	$email=strval(rtrim(trim($_POST["email"])));
	if($pass1 != $pass2)
	{
		$_SESSION["erro"]="Password1 and confirm password2 must be the same";
                redirect::location("signup.php");
	}
        
	else
	{
		$check=$user."".$email;
        $verify=verify::check($check);
		if($verify==0)
		{
			$creat=new user($user,$pass1);
			$taoacc=$creat->insertuser($user, $pass1, $email);
			if($taoacc==true)
			{
				$_SESSION["erro"]="Your account has been created ! plz login to find the cc now ";
                               redirect::location("login.php");
			}
			else
			{
				$_SESSION["erro"]="Have Mistake in registering";
                                header('location:signup.php');
			}
		}
		else
		{
			// k the dien vao database
                            $url="signup.php";
 			 			  $_SESSION["erro"]="Correct the infomation you have put";
                            redirect::location("signup.php");
			
		}
	}
  		
  	
  	
  	
	
}
else
{
	require_once 'html/signup.php';
}

?>